package com.qcby.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qcby.dao.CheckingDao;
import com.qcby.entity.Checkings;
import com.qcby.entity.ExploreScript;
import com.qcby.entity.PageResult;
import com.qcby.entity.Query.CheckingQuery;
import com.qcby.entity.Result;
import com.qcby.service.CheckingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CheckingServiceImpl implements CheckingService {
    @Autowired
    private CheckingDao checkingDao;

    @Override
    public PageResult<Checkings> list(CheckingQuery checkingQuery) {
        PageHelper.startPage(checkingQuery.getPage(), checkingQuery.getPageSize());
        List<Checkings> page1 =  checkingDao.list(checkingQuery);
        System.out.println(page1);
        Page<Checkings> page2 = (Page<Checkings>) page1;
        PageResult<Checkings> pageResult = new PageResult<>(page2.getTotal(),page2.getResult());
        return pageResult;
    }

    @Override
    public Checkings getById(int id) {
        return checkingDao.getById(id);
    }

    @Override
    public void delete(int id) {
        checkingDao.delete(id);
    }
}
